package control_centre

import (
	"fmt"
	"github.com/hajimehoshi/ebiten/v2"
	"study/PlantsVsZombies1/utils"
	"time"
)

func DisplayAdventureEntrance(screen *ebiten.Image) {
	op := &ebiten.DrawImageOptions{}
	op.GeoM.Translate(0, 0)
	screen.DrawImage(AdventureEntranceSlice[0], op)
}
func DisplayNoEntrance(screen *ebiten.Image) {
	op := &ebiten.DrawImageOptions{}
	op.GeoM.Scale(1.9, 1.9)
	op.GeoM.Translate(480, 75)
	var colorM ebiten.ColorM
	colorM.Scale(0.7, 0.7, 0.7, 1)
	op.ColorM = colorM
	screen.DrawImage(AdventureEntranceSlice[1], op)
}
func DisplayEntrance(screen *ebiten.Image) {
	op := &ebiten.DrawImageOptions{}
	op.GeoM.Scale(1.9, 1.9)
	op.GeoM.Translate(480, 75)
	screen.DrawImage(AdventureEntranceSlice[2], op)
}

// DisplayMouseClickMode 鼠标点击模式
func (g *Game) DisplayMouseClickMode(screen *ebiten.Image) {
	x, y := utils.GetCoordination()
	if x <= 775 && x >= 475 && y <= 198 && y >= 70 && g.MouseState == ClickTheMouse {
		AdventureEntranceLastTime = time.Now()
		g.GameCenterEntranceState = Activate
	}
	if g.GameCenterEntranceState == Activate {
		DisplayEntrance(screen)
	} else if g.GameCenterEntranceState == Deactivation {
		DisplayNoEntrance(screen)
	}
	if g.GameCenterEntranceState == Activate {
		var timeNum = utils.CalTimeDiff(AdventureEntranceLastTime, time.Now())

		if timeNum >= 100 {
			DisplayNoEntrance(screen)
			if timeNum >= 350 {
				EnterTheArenaPreheatTime = time.Now()
				ZombieToggleMovement = time.Now()
				//peaShootTime = time.Now()
				fmt.Println("开始冒险")
				g.GameCenter = AdventureWar
			}
		}
	}
}
